package com.panasonic.cn.cmsc;

import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;
import java.sql.SQLException;
import com.fujitsu.fks.jaaf.core.*;

public class SQLMApltime02{
	private Hashtable paramsString     = new Hashtable();
	private Hashtable paramsBigDecimal = new Hashtable();
	private Hashtable paramsFree       = new Hashtable();
	private String lastSql_ = null;

	private String getString(String name){
		if(name==null) return "";
		String returnStr = (String)paramsString.get(name);
		if(returnStr==null) return "";
		return "'"+FrameworkCommon.stringReplaceSQuote(returnStr)+"'";
	}

	private String getBigDecimal(String name){
		if(name==null) return "";
		BigDecimal returnStr = (BigDecimal)paramsBigDecimal.get(name);
		if(returnStr==null) return "";
		return returnStr.toString();
	}

	private String getFree(String name){
		if(name==null) return "";
		String returnStr = (String)paramsFree.get(name);
		if(returnStr==null) return "";
		return returnStr;
	}

	public String getLastSql(){
		return lastSql_;
	}

	public SelectResultRset SELECT_APLTIME01(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("SELECT APL_DT,");
		sql.append(" TO_CHAR(TO_DATE(APL_DT,'YYYYMMDD'),'YYYY/MM/DD') AS APL_DT_F,");
		sql.append(" TO_CHAR(TO_DATE(START_TM,'HH24MI'),'HH24:MI') AS START_TM,");
		sql.append(" TO_CHAR(TO_DATE(STOP_TM,'HH24MI'),'HH24:MI') AS STOP_TM,");
		sql.append(" TO_CHAR(RGS_DTTM,'YYYY/MM/DD HH24:MI:SS') AS RGS_DTTM,");
		sql.append(" RGS_CHRG_CD,");
		sql.append(" RGS_PGID,");
		sql.append(" TO_CHAR(UPD_DTTM,'YYYY/MM/DD HH24:MI:SS') AS UPD_DTTM,");
		sql.append(" UPD_CHRG_CD,");
		sql.append(" UPD_PGID");
		sql.append(" FROM APLTIME");
		sql.append(" ORDER BY APL_DT");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		SelectResultRset srr = db.executeQuery();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return srr;
	}

	public SelectResultRset SELECT_APLTIME02(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("SELECT APL_DT,");
		sql.append(" TO_CHAR(TO_DATE(APL_DT,'YYYYMMDD'),'YYYY/MM/DD') AS APL_DT_F,");
		sql.append(" TO_CHAR(TO_DATE(START_TM,'HH24MI'),'HH24:MI') AS START_TM,");
		sql.append(" TO_CHAR(TO_DATE(STOP_TM,'HH24MI'),'HH24:MI') AS STOP_TM,");
		sql.append(" TO_CHAR(RGS_DTTM,'YYYY/MM/DD HH24:MI:SS') AS RGS_DTTM,");
		sql.append(" RGS_CHRG_CD,");
		sql.append(" RGS_PGID,");
		sql.append(" TO_CHAR(UPD_DTTM,'YYYY/MM/DD HH24:MI:SS') AS UPD_DTTM,");
		sql.append(" UPD_CHRG_CD,");
		sql.append(" UPD_PGID");
		sql.append(" FROM APLTIME");
		sql.append(" WHERE APL_DT >"+((getString("FRM_DT").equals(""))?" is null ":"=")+getString("FRM_DT")+"");
		sql.append(" ORDER BY APL_DT");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		SelectResultRset srr = db.executeQuery();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return srr;
	}

	public SelectResultRset SELECT_APLTIME03(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("SELECT APL_DT,");
		sql.append(" TO_CHAR(TO_DATE(APL_DT,'YYYYMMDD'),'YYYY/MM/DD') AS APL_DT_F,");
		sql.append(" TO_CHAR(TO_DATE(START_TM,'HH24MI'),'HH24:MI') AS START_TM,");
		sql.append(" TO_CHAR(TO_DATE(STOP_TM,'HH24MI'),'HH24:MI') AS STOP_TM,");
		sql.append(" TO_CHAR(RGS_DTTM,'YYYY/MM/DD HH24:MI:SS') AS RGS_DTTM,");
		sql.append(" RGS_CHRG_CD,");
		sql.append(" RGS_PGID,");
		sql.append(" TO_CHAR(UPD_DTTM,'YYYY/MM/DD HH24:MI:SS') AS UPD_DTTM,");
		sql.append(" UPD_CHRG_CD,");
		sql.append(" UPD_PGID");
		sql.append(" FROM APLTIME");
		sql.append(" WHERE APL_DT <"+((getString("TO_DT").equals(""))?" is null ":"=")+getString("TO_DT")+"");
		sql.append(" ORDER BY APL_DT");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		SelectResultRset srr = db.executeQuery();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return srr;
	}

	public SelectResultRset SELECT_APLTIME04(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("SELECT APL_DT,");
		sql.append(" TO_CHAR(TO_DATE(APL_DT,'YYYYMMDD'),'YYYY/MM/DD') AS APL_DT_F,");
		sql.append(" TO_CHAR(TO_DATE(START_TM,'HH24MI'),'HH24:MI') AS START_TM,");
		sql.append(" TO_CHAR(TO_DATE(STOP_TM,'HH24MI'),'HH24:MI') AS STOP_TM,");
		sql.append(" TO_CHAR(RGS_DTTM,'YYYY/MM/DD HH24:MI:SS') AS RGS_DTTM,");
		sql.append(" RGS_CHRG_CD,");
		sql.append(" RGS_PGID,");
		sql.append(" TO_CHAR(UPD_DTTM,'YYYY/MM/DD HH24:MI:SS') AS UPD_DTTM,");
		sql.append(" UPD_CHRG_CD,");
		sql.append(" UPD_PGID");
		sql.append(" FROM APLTIME");
		sql.append(" WHERE APL_DT >"+((getString("FRM_DT").equals(""))?" is null ":"=")+getString("FRM_DT")+" ");
		sql.append(" AND APL_DT <"+((getString("TO_DT").equals(""))?" is null ":"=")+getString("TO_DT")+"");
		sql.append(" ORDER BY APL_DT");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		SelectResultRset srr = db.executeQuery();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return srr;
	}

	public int DELETE_APLTIME01(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("DELETE APLTIME");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		int updateCount = db.executeUpdate();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return updateCount;
	}

	public int DELETE_APLTIME02(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("DELETE APLTIME");
		sql.append(" WHERE APL_DT >"+((getString("FRM_DT").equals(""))?" is null ":"=")+getString("FRM_DT")+"");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		int updateCount = db.executeUpdate();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return updateCount;
	}

	public int DELETE_APLTIME03(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("DELETE APLTIME");
		sql.append(" WHERE APL_DT <"+((getString("TO_DT").equals(""))?" is null ":"=")+getString("TO_DT")+"");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		int updateCount = db.executeUpdate();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return updateCount;
	}

	public int DELETE_APLTIME04(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("DELETE APLTIME");
		sql.append(" WHERE APL_DT >"+((getString("FRM_DT").equals(""))?" is null ":"=")+getString("FRM_DT")+" ");
		sql.append(" AND APL_DT <"+((getString("TO_DT").equals(""))?" is null ":"=")+getString("TO_DT")+"");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		int updateCount = db.executeUpdate();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return updateCount;
	}


	public void setFRM_DT(String value){
		if(value==null) {
			paramsString.remove("FRM_DT");
			return;
		}
		paramsString.put("FRM_DT",value);
	}


	public void setTO_DT(String value){
		if(value==null) {
			paramsString.remove("TO_DT");
			return;
		}
		paramsString.put("TO_DT",value);
	}


}
